/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-01-12 09:35:49
 * @LastEditTime : 2023-04-04 19:01:23
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Modal\TwoModalList\PlanStatAttachment.jsx
 * @Description  :
 */
import { API_LIST } from '../../Api/Api'
import { TwoAddBtn, ThrDeleteBtn, SeeEnclosure } from '../options'
export const PlanStatAttachment = async ({ upDataEvent, data, Permission }) => {
    let dataList = {
        type: '计量附件列表',
        hideInSearch: true,
        pageSize: 10,
        params: { OrderField: 'createTime@desc' },
        classification: 'TableModal',
        get: API_LIST([data.uuid])['getPlanStatAttachment'],
        additional: { key: 'planStatUuid', value: 'uuid' },
        options: [
            Permission.findIndex(v => v.uuid === '4aaf53ba-42a7-4349-b56c-476be223346a') !== -1 && (
                <TwoAddBtn
                    upDataEvent={upDataEvent}
                    title="添加附件"
                    ThrKey="ThrModal"
                    value="PlanStatAttachment"
                    data={data}
                />
            ),
        ],
        columns: [
            {
                dataIndex: 'tableName',
                title: '名称',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'sortId',
                title: '排序',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
            },
            {
                title: '创建时间',
                dataIndex: 'createTime',
                valueType: 'input',
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 500,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { attachment } = record
                    return [
                        attachment?.fileUrl && (
                            <SeeEnclosure
                                key="seeFile"
                                title="查看附件"
                                data={{
                                    className: 'Admin',
                                    url: attachment.fileUrl,
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === 'f395a7ed-64f2-416e-bbfe-63e1c3ac81fc') !== -1 && (
                            <ThrDeleteBtn
                                key="delete"
                                record={record.uuid}
                                upDataEvent={upDataEvent}
                                data={{ key: 'delete', url: 'delPlanStatAttachment', title: '删除附件' }}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return dataList
}
